import { Drash } from '../mod.ts';

export class ST_HomeResource extends Drash.Http.Resource {
    static paths = ["/stu"];
    public GET() {
        const name = 'jiangkun';
        const list = [
            {
                name: 'a',
                age: 12
            },
            {
                name: 'a1',
                age: 10
            },
        ];
        const html = `
            <html>
                <body>
                    <p>
                        name: ${name}
                    </p>
                    <table border="1">
                        <tr><th>name</th><th>age</th></tr>
                        ${list.reduce((t, { name, age }) => {
                            t += `<tr><th>${name}</th><th>${age}</th></tr>`;
                            return t;
                        }, '')}
                    </table>
                <body>
            <html>
        `;
        this.response.body = html;
        return this.response;
    }
}